//
//  GWShopLeftCell.m
//  GiftWanted
//
//  Created by lanou on 15/11/12.
//  Copyright © 2015年 陈文杰. All rights reserved.
//

#import "GWShopLeftCell.h"
#import "UIImageView+WebCache.h"

#define w (SCREEN_WIDTH-22)/2

@implementation GWShopLeftCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.backgroundColor = [UIColor colorWithWhite:0.913 alpha:1.000];
        
        _bgView = [[UIView alloc] initWithFrame:CGRectMake(5, 5, SCREEN_WIDTH-10, 60+(SCREEN_WIDTH-22)/2)];
        _bgView.backgroundColor = [UIColor whiteColor];
        _bgView.layer.cornerRadius = 5;
        _bgView.layer.masksToBounds = YES;
        _iconImg = [[UIImageView alloc] initWithFrame:CGRectMake(5, 5, 40, 40)];
        _iconImg.layer.borderWidth = 1;
        _iconImg.layer.borderColor = [UIColor colorWithWhite:0.849 alpha:1.000].CGColor;
        _iconImg.layer.masksToBounds = YES;
        _nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(50, 5, 200, 20)];
        _nameLabel.font = [UIFont systemFontOfSize:15];
        _descLabel = [[UILabel alloc] initWithFrame:CGRectMake(50, 25, 200, 20)];
        _descLabel.textColor = [UIColor lightGrayColor];
        _descLabel.font = [UIFont systemFontOfSize:12];
        
        UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(SCREEN_WIDTH - 70, 15, 60, 20)];
        label.text = @"品牌主页>";
        label.textColor = [UIColor lightGrayColor];
        label.font = [UIFont systemFontOfSize:12];
        
        [self.bgView addSubview:_iconImg];
        [self.bgView addSubview:_nameLabel];
        [self.bgView addSubview:_descLabel];
        [self.bgView addSubview:label];
        [self.contentView addSubview:_bgView];
    }
    return self;
}

- (void)setConfigureModel:(GWShopModel *)configureModel {
    _configureModel = configureModel;
    [_iconImg sd_setImageWithURL:[NSURL URLWithString:configureModel.icon_url]];
    _nameLabel.text = configureModel.name;
    _descLabel.text = configureModel.desc;
    
    UIImageView *bigImg = [[UIImageView alloc] initWithFrame:CGRectMake(SCREEN_WIDTH/2-4, 55, w, w)];
    [bigImg sd_setImageWithURL:[NSURL URLWithString:configureModel.image_urls[0]]];
    [self.bgView addSubview:bigImg];
    
    UIImageView *img1 = [[UIImageView alloc] initWithFrame:CGRectMake(5, 55, w/2-1, w/2-1)];
    [img1 sd_setImageWithURL:[NSURL URLWithString:configureModel.image_urls[1]]];
    [self.bgView addSubview:img1];
    
    UIImageView *img2 = [[UIImageView alloc] initWithFrame:CGRectMake(w/2+6, 55, w/2-1, w/2-1)];
    [img2 sd_setImageWithURL:[NSURL URLWithString:configureModel.image_urls[2]]];
    [self.bgView addSubview:img2];
    
    UIImageView *img3 = [[UIImageView alloc] initWithFrame:CGRectMake(5, 56+w/2, w/2-1, w/2-1)];
    [img3 sd_setImageWithURL:[NSURL URLWithString:configureModel.image_urls[3]]];
    [self.bgView addSubview:img3];
    
    UIImageView *img4 = [[UIImageView alloc] initWithFrame:CGRectMake(w/2+6, 56+w/2, w/2-1, w/2-1)];
    [img4 sd_setImageWithURL:[NSURL URLWithString:configureModel.image_urls[4]]];
    [self.bgView addSubview:img4];
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
